<h2>Why is this an issue?</h2>
<p>Using <code>.Count()</code> to test for emptiness works, but using <code>.Any()</code> makes the intent clearer, and the code more readable.
However, there are some cases where special attention should be paid:</p>
<ul>
  <li> if the collection is an <code>EntityFramework</code> or other ORM query, calling <code>.Count()</code> will cause executing a potentially
  massive SQL query and could put a large overhead on the application database. Calling <code>.Any()</code> will also connect to the database, but
  will generate much more efficient SQL. </li>
  <li> if the collection is part of a LINQ query that contains <code>.Select()</code> statements that create objects, a large amount of memory could
  be unnecessarily allocated. Calling <code>.Any()</code> will be much more efficient because it will execute fewer iterations of the enumerable.
  </li>
</ul>
<h3>Noncompliant code example</h3>
<pre>
Private Function HasContent(Strings As IEnumerable(Of String)) As Boolean
    Return Strings.Count() &gt; 0      ' Noncompliant
End Function

Private Function HasContent2(Strings As IEnumerable(Of String)) As Boolean
    Return Strings.Count() &gt;= 1     ' Noncompliant
End Function

Private Function IsEmpty(Strings As IEnumerable(Of String)) As Boolean
    Return Strings.Count() = 0      ' Noncompliant
End Function
</pre>
<h3>Compliant solution</h3>
<pre>
Private Function HasContent(Strings As IEnumerable(Of String)) As Boolean
    Return Strings.Any
End Function

Private Function HasContent2(Strings As IEnumerable(Of String)) As Boolean
    Return Strings.Any
End Function

Private Function IsEmpty(Strings As IEnumerable(Of String)) As Boolean
    Return Not Strings.Any
End Function
</pre>

